package com.xiaomi.shwx.controller.engineer;

import com.xiaomi.shwx.common.result.Result;
import com.xiaomi.shwx.entity.pojo.WorkOrder;
import com.xiaomi.shwx.entity.request.AcceptOrderRequest;
import com.xiaomi.shwx.service.EngineerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping("/api/engineer")
public class EngineerController {
    @Resource
    private EngineerService engineerService;

    /**
     * 工程师查看个人工单的详细信息
     * @param id
     * @return
     */
    @GetMapping("getOrderDetails/{workorder_Id}")
    public Result<WorkOrder> getOrderDetails(@PathVariable(value = "workorder_Id") String id) {
        log.info("工程师查看个人工单的详细信息:{}", id);
        return Result.ok(engineerService.getOrderDetails(id));
    }

    /**
     * 工程师接单
     *
     * @param request
     * @return
     */
    @PostMapping("/acceptOrder")
    public Result<Boolean> acceptOrder(@RequestBody AcceptOrderRequest request) {
        log.info("工程师接单，工单id: {}, 工程师id: {}", request.getOrderId(), request.getEngineerId());
        return Result.ok(engineerService.acceptOrder(request));
    }

}
